import {Button,Mention,Timeline,Icon,message} from 'antd';
import {WeaRichText} from 'ecCom';
import './style/index.css';
import * as FormUtil from "../../../util/formUtil";
const ButtonGroup = Button.Group;
import Comment from './comment/Comment';
import Log from './log/Log';

class Dynamic extends React.Component {
    constructor(props) {
		super(props);
        
        this.state={dynamicKey:'comment'};
    }
    
    

	render() {
        const content = this.getContent();
		return (
            <div>
                <div style={{paddingTop:'5px',textAlign:'right',paddingRight:'5px'}}>
                    <ButtonGroup size="small" >
                        <Button type={this.state.dynamicKey == "comment" ? 'primary' :'ghost'} onClick={()=>this.onDynamicClick('comment')}>评论</Button>
                        <Button type={this.state.dynamicKey == "atme" ? 'primary' :'ghost'} onClick={()=>this.onDynamicClick('atme')}>与我相关</Button>
                        <Button type={this.state.dynamicKey == "dynamic" ? 'primary' :'ghost'} onClick={()=>this.onDynamicClick('dynamic')}>动态</Button>
                    </ButtonGroup>
                </div>

                <div>
                    {content}
                </div>
            </div>
        );
    };

    //动态评论切换
    onDynamicClick=(value)=>{
    	this.setState({
			dynamicKey:value
    	})
    }

    getContent = () =>{
        const {dynamicKey} =  this.state;
        const {refId} = this.props; 
        return [
            dynamicKey=='dynamic'&&(<Log refId={refId}/>),
            dynamicKey!=='dynamic'&&(<Comment dynamicKey={dynamicKey} refId={refId}/>)
        ];
    }
    
}

export default Dynamic;